<?php

use yii\helpers\Html;
use yii\widgets\DetailView;

/* @var $this yii\web\View */
/* @var $model app\modules\admin\models\FormFields */

$this->title = $model->id;
$this->params['breadcrumbs'][] = ['label' => 'Form Fields', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="form-fields-view">

    <h1><?= Html::encode($this->title) ?></h1>

    <p>
        <?= Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
        <?= Html::a('Delete', ['delete', 'id' => $model->id], [
            'class' => 'btn btn-danger',
            'data' => [
                'confirm' => 'Are you sure you want to delete this item?',
                'method' => 'post',
            ],
        ]) ?>
    </p>

    <?= DetailView::widget([
        'model' => $model,
        'attributes' => [
            'id',
            'tenant',
            [
                'attribute'=> "required_form",
                'value'=> function($data){
                    $required_form = json_decode($data->required_form);
                    $data = "";
                    foreach ($required_form as $required => $v){
                        if ($v == "USER_FORM_INFO_FLAG_MOBILE"){
                            $data.= "手机号";
                        }
                        if ($v == "USER_FORM_INFO_FLAG_SEX"){
                            $data.="性别-";
                        }
                        if ($v == "USER_FORM_INFO_FLAG_NAME"){
                            $data.="姓名-";
                        }
                        if ($v == "USER_FORM_INFO_FLAG_BIRTHDAY"){
                            $data.="生日-";
                        }
                        if ($v == "USER_FORM_INFO_FLAG_IDCARD"){
                            $data.="身份证-";
                        }
                        if ($v == "USER_FORM_INFO_FLAG_EMAIL"){
                            $data.="邮箱-";
                        }
                        if ($v == "USER_FORM_INFO_FLAG_LOCATION"){
                            $data.="详细地址-";
                        }
                        if ($v == "USER_FORM_INFO_FLAG_INDUSTRY"){
                            $data.="行业-";
                        }
                        if ($v == "USER_FORM_INFO_FLAG_INCOME"){
                            $data.="收入-";
                        }
                        if ($v == "USER_FORM_INFO_FLAG_HABIT"){
                            $data.="兴趣爱好-";
                        }
                    }

                    return rtrim($data, "-");;
                }
            ],

            [
                'attribute'=> "required_form",
                'value'=> function($data){
                    $required_form = json_decode($data->optional_form);
                    $data = "";
                    foreach ($required_form as $required => $v){
                        if ($v == "USER_FORM_INFO_FLAG_MOBILE"){
                            $data.= "手机号";
                        }
                        if ($v == "USER_FORM_INFO_FLAG_SEX"){
                            $data.="性别-";
                        }
                        if ($v == "USER_FORM_INFO_FLAG_NAME"){
                            $data.="姓名-";
                        }
                        if ($v == "USER_FORM_INFO_FLAG_BIRTHDAY"){
                            $data.="生日-";
                        }
                        if ($v == "USER_FORM_INFO_FLAG_IDCARD"){
                            $data.="身份证-";
                        }
                        if ($v == "USER_FORM_INFO_FLAG_EMAIL"){
                            $data.="邮箱-";
                        }
                        if ($v == "USER_FORM_INFO_FLAG_LOCATION"){
                            $data.="详细地址-";
                        }
                        if ($v == "USER_FORM_INFO_FLAG_INDUSTRY"){
                            $data.="行业-";
                        }
                        if ($v == "USER_FORM_INFO_FLAG_INCOME"){
                            $data.="收入-";
                        }
                        if ($v == "USER_FORM_INFO_FLAG_HABIT"){
                            $data.="兴趣爱好-";
                        }
                    }

                    return rtrim($data, "-");;
                }
            ],
        ],
    ]) ?>

</div>
